global dlogNameList, dlogLocationList, dlogSpriteList, dlogButtonList, dlogButtonLocationList, dlogButtonSprites
setDialogOpen(0)
set dlogNameList to ["quitDialog"]
set dlogLocationList to [[140, 140]]
set dlogSpriteList to [46]
set dlogButtonList to [[#Yes: 47, #No: 48]]
set dlogButtonLocationList to [[[240, 90], [70, 90]]]
end
on openDialog dialogBoxName
global dlogNameList, dlogLocationList, dlogSpriteList, dlogButtonList, dlogButtonLocationList, dlogButtonSprites
set the mouseDownScript to "beepIfOutsideDialog"
set theIndex to getPos(dlogNameList, dialogBoxName)
set cNum to the number of cast dialogBoxName
set X to getX(getAt(dlogLocationList, theIndex))
set Y to getY(getAt(dlogLocationList, theIndex))
set sNum to getAt(dlogSpriteList, theIndex)
if cNum > 0 then
setDialogOpen(dialogBoxName)
puppetSprite(sNum, 1)
set the castNum of sprite sNum to cNum
set the locH of sprite sNum to X
set the locV of sprite sNum to Y
set theButtonList to getAt(dlogButtonList, theIndex)
set theLocList to getAt(dlogButtonLocationList, theIndex)
repeat with i = 1 to count(theButtonList)
set sButton to getAt(theButtonList, i)
puppetSprite(sButton, 1)
set the castNum of sprite sButton to the number of cast (string(getPropAt(theButtonList, i)) & "_B1")
set the locH of sprite sButton to X + getX(getAt(theLocList, i))
set the locV of sprite sButton to Y + getY(getAt(theLocList, i))
end repeat
updateStage()
end if
end
on checkDialogs
global dlogNameList, dlogLocationList, dlogSpriteList, dlogButtonList, dlogButtonLocationList, dlogButtonSprites, movieFileExtension
set theDialog to "quitDialog"
set cNum to the number of cast theDialog
if isDialogOpen() = EMPTY then
return 0
else
if isDialogOpen() = theDialog then
set theIndex to getPos(dlogNameList, theDialog)
set theButtonList to getAt(dlogButtonList, theIndex)
if buttonClicked(theButtonList, #Yes, 1) then
closeDialog(theDialog)
play movie "quit" & movieFileExtension
else
if buttonClicked(theButtonList, #No, 1) then
closeDialog(theDialog)
end if
end if
end if
end if
return 1
end
on closeDialog dialogBoxName
global dlogNameList, dlogLocationList, dlogSpriteList, dlogButtonList, dlogButtonLocationList, dlogButtonSprites
set theIndex to getPos(dlogNameList, dialogBoxName)
set cNum to the number of cast "EmptyPaintObject"
set sNum to getAt(dlogSpriteList, theIndex)
if (cNum > 0) and (sNum > 0) and (sNum < 48) then
setDialogOpen(EMPTY)
puppetSprite(sNum, 1)
set the castNum of sprite sNum to cNum
set theButtonList to getAt(dlogButtonList, theIndex)
repeat with i = 1 to count(theButtonList)
set sButton to getAt(theButtonList, i)
puppetSprite(sButton, 1)
set the castNum of sprite sButton to cNum
end repeat
updateStage()
set the mouseDownScript to EMPTY
end if
end
on setDialogOpen theDialog
global gCurrentDialog
set gCurrentDialog to theDialog
end
on isDialogOpen
global gCurrentDialog
return gCurrentDialog
end
on mouseInDialogBox dialogBoxSprite
global sDialogBox
if (the mouseH < the left of sprite dialogBoxSprite) or (the mouseH > the right of sprite dialogBoxSprite) or (the mouseV < the top of sprite dialogBoxSprite) or (the mouseV > the bottom of sprite dialogBoxSprite) then
return 0
else
return 1
end if
end
on beepIfOutsideDialog
global dlogNameList, dlogLocationList, dlogSpriteList, dlogButtonList, dlogButtonLocationList, dlogButtonSprites